package com.example.springboot1.mapper;

import com.example.springboot1.pojo.Login;
import com.example.springboot1.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface LoginMapper {
    @Select("select * from login where id = #{id}")
    Login getLoginById(Integer id);

    //登录
    @Select("select * from login where user_name = #{user_name} and user_pwd = #{user_pwd}")
    Login findLogin(String user_name,String user_pwd);

    //登录-根据姓名查询
    @Select("select * from login where user_name = #{user_name}")
    Login findLoginByName(String user_name);

    //分页
    @Select("select * from login limit #{pageNum},#{pageSize}")
    List<Login> LoginPage(Integer pageNum, Integer pageSize);

    @Insert("insert into login (user_name,user_pwd) values (#{user_name},#{user_pwd})")
    int InsertLogin (Login login);

    @Update("update login set user_name = #{user_name},user_pwd = #{user_pwd}")
    int updateLogin (Login login);

    @Delete("delete from login where id = #{id}")
    int deleteLogin (Integer id);
}
